package com.gzc.pm.util
{
	import com.gzc.pm.bean.CollectionBean;
	import com.gzc.pm.bean.DetectioncardBean;
	import com.gzc.pm.dao.CollectionDao;
	import com.gzc.pm.dao.DetectionCardDao;
	
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import mx.rpc.events.ResultEvent;

	public class TempUtil
	{
		public function TempUtil()
		{
			_dao = new DetectionCardDao();
		}
		
		private var _dao:DetectionCardDao;
		
		public function generateData():void{
			var timer:Timer = new Timer(5000);
			timer.addEventListener(TimerEvent.TIMER, onTimer);
			timer.start();
		}
		private function onTimer(e:TimerEvent):void{
			add();
		}
		
		public function add():void{
			var randomNum:Number = Math.random();
			
			var bean:DetectioncardBean = new DetectioncardBean();
			bean.type = '1';
			bean.state = '0';
			bean.pline = 6;
			bean.proute = 53
			var date:Date = new Date();
			var y:String = String(date.fullYear);
			var m:String = date.month<9?'0'+String(date.month+1):String(date.month+1);
			var d:String = date.date<10?'0'+String(date.date):String(date.date);
			var h:String = date.hours<10?'0'+String(date.hours):String(date.hours);
			var m1:String = date.minutes<10?'0'+String(date.minutes):String(date.minutes);
			var s:String = date.seconds<10?'0'+String(date.seconds):String(date.seconds);
			bean.testDate = y+m+d+h+m1+s;
			
			bean.productId = y+'00'+String(int(Math.random()*899+100))+'03183';
			bean.v10 = (Math.random()*10.00+60.00).toFixed(3);
			bean.v11 = (Math.random()*10.00+10.00).toFixed(3);
			bean.v12 = (Math.random()*10.00+20.00).toFixed(3);
			bean.v13 = (Math.random()*10.00+0.00).toFixed(3);
			bean.v14 = (Math.random()*5.00+10.00).toFixed(3);
			bean.v15 = (Math.random()*5.00+22.00).toFixed(3);
			bean.v16 = (Math.random()*4.00+23.00).toFixed(3);
			bean.v17 = (Math.random()*12.00+16.00).toFixed(3);
			bean.v18 = (Math.random()*1.00+421.00).toFixed(3);
			bean.v19 = (Math.random()*1.00+421.00).toFixed(3);
			bean.v20 = (Math.random()*1.00+421.00).toFixed(3);
			bean.v21 = (Math.random()*1.00+421.00).toFixed(3);
			bean.v22 = (Math.random()*1.00+125.00).toFixed(3);
			bean.v23 = (Math.random()*1.00+125.00).toFixed(3);
			bean.v24 = (Math.random()*1.00+125.00).toFixed(3);
			bean.v25 = (Math.random()*1.00+125.00).toFixed(3);
			bean.v26 = (Math.random()*2.00+21.00).toFixed(3);
			bean.v27 = (Math.random()*2.00+21.00).toFixed(3);
			
			_dao.add(bean, function(e:ResultEvent):void{}); 
		}
		
	}
}